package com.lyn.anr

import com.android.build.api.instrumentation.InstrumentationScope
import com.android.build.api.variant.AndroidComponentsExtension
import com.android.build.api.variant.Variant
import org.gradle.api.Plugin
import org.gradle.api.Project

/**
 *
 * @author longyn 2025/07/14
 * @version 1.0.0
 */
class AnrPlugin : Plugin<Project>{
    override fun apply(project: Project) {
        project.plugins.withId("com.android.application"){
            val androidComponentsExtension = project.extensions.getByType(AndroidComponentsExtension::class.java)
            androidComponentsExtension.onVariants { variant: Variant ->
                variant.instrumentation.apply {
                    transformClassesWith(AnrClassVisitorFactory::class.java,InstrumentationScope.ALL){}
                }
            }
        }
    }
}